Release 10.1A: OpenEdge Data Management:
DataServer for ORACLE
Error handling
Attempting to add a duplicate record is a common data-entry error. For example, the user might try to create a record, such as a
customerrecord, using a unique key that already exists in the database. If acustomerrecord already exists where thecust-numequals 1, and the user tries to add anothercustomerwith the samecust-num, the Progress 4GL generates an error. When this type of error occurs, the Progress 4GL tries to resolve the error by working its way back through the procedure, looking at each block header until it finds the closest block that has the error property. It then undoes and retries the block. See OpenEdge Development: Progress 4GL Handbook for more information about error handling.Because the DataServer is accessing a non-OpenEdge database, it cannot detect duplicate key errors until the end of a transaction block. As a result, if the error occurs in a subtransaction, the Progress 4GL cannot detect the error until the end of the entire transaction block, so it performs default error handling for the transaction block.
This code example illustrates the Progress 4GL and DataServer error handling:
This procedure displays the screen shown below. The procedure prompts the user to enter data into the
cust-numfield, and then into thest-abbrfield. Suppose a user enters an existingstate(for example, NH) while the 4GL is processing theDOblock. With an OpenEdge database if a duplicate key entry occurs in theDOblock, control returns to theDOblock. After the 4GL displays a message that the record exists, it reprompts the user for the state abbreviation. For example:
![]()
With the OpenEdge DataServer for ORACLE, if a duplicate key entry occurs in the
DOblock, the 4GL returns control to theREPEATblock. The procedure reprompts the user to enter the customer number after the inner transaction completes. For example:
![]()
When two users simultaneously attempt to create records with duplicate keys, another difference in behavior occurs. The Progress 4GL raises an error immediately, but ORACLE raises an error after the first transaction commits, and only if the second transaction does not roll back. It is important to note that the second attempt to create a duplicate key will wait until the first user sends the transaction. ORACLE does not notify the DataServer that it is waiting for the other user’s transaction to end, so the DataServer cannot produce a message on the client indicating the lock wait situation.
To avoid this difference, change the scope of the transaction so that it completes more quickly or make the key nonunique and enforce uniqueness at the application level. Another technique is to use a
RELEASEorVALIDATEstatement when you check for the key’s uniqueness.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |